package top.kaoshanji.p1ch06b;

/**
 * 代码清单-p1ch06b-127页a：实例初始化
 * author kaoshanji
 * ^_^
 * create time 2025/3/8 18:14
 */
public class Mugs {

    Mug mug1;
    Mug mug2;

    // 每次创建对象时都会执行一遍
    {
        mug1 = new Mug(1);
        mug2 = new Mug(2);
        System.out.println("mug1 & mug2 initialized");
    }

    Mugs() {
        System.out.println("Mugs()");
    }

    Mugs(int i) {
        System.out.println("Mugs(int)");
    }

    public static void main(String[] args) {
        System.out.println("Inside main()");
        new Mugs();
        System.out.println("new Mugs() completed");
        new Mugs(1);
        System.out.println("new Mugs(1) completed");
    }

}

class Mug {
    Mug(int marker) {
        System.out.println("Mug(" + marker + ")");
    }
}
